package com.foreknow.demo16;

import java.util.*;

public class ExamCollection {

    public Map<String,User> m1(){
        Map<String,User> map11 = new HashMap();
        User u1 = new User();
        //要将对象保存到Map容器里
        u1.setName("u1");
        User u2 = new User();
        u2.setName("u2");
        //要将对象保存到Map容器里
        map11.put("1",u1);
        map11.put("2",u2);
        return map11;
    }


    public static void main(String[] args) {
        List<Map<String,User>> list =new ArrayList<>();
        Map<String,User> map1 = new HashMap<>();
        User u1 = new User();
        //要将对象保存到Map容器里
        u1.setName("u1");
        User u2 = new User();
        u2.setName("u2");
        //要将对象保存到Map容器里
        map1.put("1",u1);
        map1.put("2",u2);
        Map<String,User> map2 = new HashMap<>();
        User u3 = new User();
        u3.setName("u3");
        User u4 = new User();
        u4.setName("u4");
        map2.put("1",u3);
        map2.put("2",u4);
        Map<String,User> map3 = new HashMap<>();
        User u5 = new User();
        u5.setName("u5");
        User u6 = new User();
        u6.setName("u6");
//        要将对象保存到Map容器里
        map3.put("1",u5);
        map3.put("2",u6);




        //就Map放在List里
        list.add(map1);
        list.add(map2);
        list.add(map3);

        //遍历输出

        for (int i = 0;i<list.size();i++){
            Map<String,User> map = list.get(i);
          Set<Map.Entry<String,User>> set = map.entrySet();
         Iterator<Map.Entry<String,User>> it = set.iterator();
         while (it.hasNext()){
             Map.Entry<String,User> m =it.next();
            String key = m.getKey();
            User value = m.getValue();
             System.out.println(key+"__-------"+value.getName());
         }
        }

    }
}
